/*
 * Copyright © 2008 PCCW Solutions All right reserved.
 *
 */
package com.blues.framework.db;



import java.sql.SQLException;



/**
 * 数据库JDBC操作辅助类
 * @author: Jones Wang in 2006-8-2 20:12:22.
 */
public class DbException extends SQLException {
	private int dbFlag; // 存储过程返回值标识
	private String dbMessage; // 存储过程返回信息
	private Exception dbException = null; // 原始异常对象

	/**
	 * 构造函数
	 * @param dbFlag 存储过程返回值标识
	 * @param dbMessage 存储过程返回信息
	 */
    public DbException(int dbFlag, String dbMessage) {
    	super(dbMessage);
		this.dbFlag = dbFlag;
		this.dbMessage = dbMessage;
	}

	/**
	 * 构造函数
	 * @param dbFlag 存储过程返回值标识
	 * @param dbMessage 存储过程返回信息
	 * @param exp 原始异常信息
	 */
    public DbException(int dbFlag, String dbMessage, Exception exp) {
    	super(dbMessage);
		this.dbFlag = dbFlag;
		this.dbMessage = dbMessage;
		this.dbException = exp;
	}

	public int getDbFlag() {
		return this.dbFlag;
	}
	public void setDbFlag(int dbFlag) {
		this.dbFlag = dbFlag;
	}

	public String getDbMessage() {
		return this.dbMessage;
	}
	public void setDbMessage(String dbMessage) {
		this.dbMessage = dbMessage;
	}

	public Exception getDbException() {
		return this.dbException;
	}
	public void setDbException(Exception dbException) {
		this.dbException = dbException;
	}

	public String toString() {
		if (dbException == null) {
			return "com.pccw.commons.database.DbException: {dbFlag: " + dbFlag + ", dbMessage: " + dbMessage + "}";
		}
		return "com.pccw.commons.database.DbException: {dbFlag: " + dbFlag + ", dbMessage: " + dbMessage + "}\r\n" + dbException.toString();
	}
}
